/*
  Collision Detection and Response Benchmark
  Ben Gilbert
  26th of February 2008
*/
#include <irrlicht.h>
#include <iostream>
#include <string>
#include "game.h"
using namespace irr;

#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
#endif

int main(int argc, char* argv[])
{
  bool useCollisionResponseAnimators = false;
  unsigned frameLimit = 0;
  if(argc != 3)
    {
      std::cout << "Incorrect argument format: benchmark [y or n] framelimit" << std::endl;
      exit(1);
    }
  char yesStr[] = "y";
  char noStr[] = "n";
  if(strcmp(argv[1], yesStr) == 0)
    {
      std::cout << "here" << std::endl;
      useCollisionResponseAnimators = true;
    } 
  else
    {
      if(strcmp(argv[1], noStr) != 0)
	{
	    std::cout << "Incorrect argument format: benchmark [y or n] framelimit " << std::endl;
	    exit(1);
	} 
    }
  frameLimit = static_cast<unsigned>(atoi( argv[2]) );
  Game game;
  // the member functions of game must be called in this order
  game.createDevice();
  game.createVideoDriver();
  game.createSceneManager();
  game.loadQuakeMap();
  game.loadQuakeMesh();
  game.createQuakeSceneNode();
  game.createCamera();
  game.createTriangleSelector();
  //game.addCollisionResponseAnimatorToCamera();
  game.createTarget();
  game.addLight();
  game.createBoxes();
  if(useCollisionResponseAnimators) 
    {
      game.addCollisionResponseAnimatorToBoxes();
    }
  return game.loop(frameLimit);
}

